package com.ysd.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ysd.entity.Recommend;
import com.ysd.service.RecommendConditionService;
import com.ysd.util.Result;

@Controller
public class RecommendConditionController {

	
	@Autowired
	private RecommendConditionService rcService;
	
	
	@RequestMapping("findRecommend")
	@ResponseBody
	public Object getRecommend(Recommend rend) {
		rend.setPage((rend.getPage()-1)*rend.getLimit());
	List<Recommend>	list=rcService.findRecommend(rend);
	int	n=rcService.getPage(rend);
	
	if(list!=null) {
		return Result.toClient("0", "查询成功", n, list);
	} else {
		return Result.toClient("1", "查询失败", null, null);
	}
	
		
	}
	
	@RequestMapping("updateRecommend")
	@ResponseBody
	public String updateRecommend(Recommend recommend) {
		int	n=rcService.updateRecommend(recommend);
		
		if(n>0) {
			return Result.toClient("0", "修改成功", n, null);
		} else {
			return Result.toClient("1", "修改失败", null, null);
		}
			
		
		
	}
	
	@RequestMapping("deleteRecommend")
	@ResponseBody
	public String updateRecommend(int bannerId) {
		int	n=rcService.deleteRecommend(bannerId);
		if(n>0) {
			return Result.toClient("0", "删除成功", null);
		} else {
			return Result.toClient("1", "删除失败", null);
		}
		
		
	}
}
